package org.jiajie.coffeecodes.ali;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author jay
 */
public class SdfTest {

    public static void main(String[] args) throws ParseException {
        // Date 转 String
        Date data = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
        System.out.println(sdf.format(Calendar.getInstance().getTime()));

        String dataStr = sdf.format(data);
        System.out.println(dataStr);

        // String to Data
        System.out.println(sdf.parse(dataStr));
    }
}
